package myufferdStresmDmo1;

import java.io.*;

/**
 * ClassName:    BufferedStreamDemo2
 * Description:  缓冲流练习,一次读写一个字节数组
 * Author:       于子续
 * Date:         2024/10/10 上午9:36
 * Version:      1.0
 **/
public class BufferedStreamDemo2 {
    public static void main(String[] args) throws IOException {

        // 创建缓冲输入流对象
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("a.txt"));
        // 创建缓冲输出流对象
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("b.txt"));

        // 读取a.txt文件内容，并写入到b.txt文件中
        int len = 0;
        byte[] bytes = new byte[1024];
        while(((len=bis.read(bytes))!=-1)){
            bos.write(bytes,0,len);
        }

        //关闭流
        bos.close();
        bis.close();

    }
}
